package org.compression.services.imp;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

import org.common.util.PasswordEncrypt;
import org.compression.mapper.UserManagmentMapper;
import org.compression.services.UserManagmentSerivce;
import org.model.auth.User;
import org.model.business.UserManagment;
import org.model.comm.Page;
import org.model.comm.UpdateModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class UserManagmentServiceImp extends UserManagmentSerivce<UserManagmentMapper,UserManagment> {
			
	@Autowired
	UserManagmentMapper mUserManagmentMapper;
	
	//修改密码
	@Override
		public void updatePassWord(UpdateModel<UserManagment> mAddModel) {
			Page mPage =mAddModel.getmPage();
			UserManagment user=(UserManagment) mAddModel.getmBookMagament();
			try {
				user.setPassword(PasswordEncrypt.encodeByMd5(user.getPassword()));
			} catch (NoSuchAlgorithmException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			//mRedisUtil.del(this.getClass().getName()+"."+this.getClass().getDeclaredMethods()[0].getName()+"args:"+mPage.getCurrentPageNum()+mPage.getPageSize());
			mUserManagmentMapper.updateByPrimaryKeySelective(user);
		}
	
}
